Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

query-string

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-string

Parse and stringify URL query strings

  • 4.3.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is query-string?

The query-string npm package is used for parsing and stringifying URL query strings. It provides a simple API for dealing with query strings in a way that is both convenient and cross-browser compatible.

What are query-string's main functionalities?

Parsing query strings

This feature allows you to parse a query string into an object. It automatically handles various edge cases and decoding of parameters.

const queryString = require('query-string');
const parsed = queryString.parse('?foo=bar');
console.log(parsed); //=> {foo: 'bar'}

Stringifying objects

This feature enables you to take an object and convert it into a URL query string. It ensures that keys and values are properly encoded.

const queryString = require('query-string');
const stringified = queryString.stringify({foo: 'bar'});
console.log(stringified); //=> 'foo=bar'

Extracting query strings

This function extracts the query string from a URL.

const queryString = require('query-string');
const extracted = queryString.extract('http://example.com/?foo=bar');
console.log(extracted); //=> '?foo=bar'

Parsing arrays and objects

The package can parse query strings with array and object syntax, turning them into the corresponding JavaScript structures.

const queryString = require('query-string');
const parsed = queryString.parse('?foo[]=bar&foo[]=baz');
console.log(parsed); //=> {foo: ['bar', 'baz']}

Other packages similar to query-string

Keywords

FAQs

Package last updated on 19 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc